import pygame
#测试代码，轮流显示两张数码兽图片，由于是透明通道，因此还要染色为黑色
pygame.init()
screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()

# 加载图片并缩放
image1 = pygame.image.load("aeroveedramon.png").convert_alpha()
image2 = pygame.image.load("aeroveedramon_at.png").convert_alpha()
image1 = pygame.transform.scale(image1, (200, 200))
image2 = pygame.transform.scale(image2, (200, 200))

# 创建反转后的图片（白色 → 黑色）
def invert_image(surface):
    inverted = surface.copy()
    inverted.fill((255, 255, 255, 255), special_flags=pygame.BLEND_RGB_SUB)  # 反转颜色
    return inverted

frames = [
    invert_image(image1),  # 反转后的图片（白色变黑色）
    invert_image(image2)
]

current_frame = 0
frame_delay = 300
last_frame_time = pygame.time.get_ticks()

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    current_time = pygame.time.get_ticks()
    if current_time - last_frame_time > frame_delay:
        current_frame = (current_frame + 1) % len(frames)
        last_frame_time = current_time

    screen.fill((255, 255, 255))  # 黑色背景
    screen.blit(frames[current_frame], (300, 200))

    pygame.display.flip()
    clock.tick(60)

pygame.quit()